package com.gotloop.jdo;

import java.io.Serializable;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

/**
 * A tag is used to classify Loops.
 * a same tag can be used for both.
 * @author jibhaine
 *
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Tag implements Serializable {

	/**
	 * Generated serial version UID.
	 */
	private static final long serialVersionUID = 7590953433462242114L;

	/**
	 * Tag Primary Key.
	 */
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
    
	/**
	 * Tag Primary Key.
	 */
	@Persistent
	private String name;

	/**
	 * Public constructor.
	 * @param pName the tag label
	 */
	public Tag(String pName) {
		super();
		this.name = pName;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Tag [name=" + name + "]";
	}

	/**
	 * Get accessor for key.
	 * @return the key to get
	 */
	public Key getKey() {
		return key;
	}

	/**
	 * Set accessor for key.
	 * @param pKey the key to set
	 */
	public void setKey(Key pKey) {
		this.key = pKey;
	}

	/**
	 * Get accessor for name.
	 * @return the name to get
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set accessor for name.
	 * @param pName the name to set
	 */
	public void setName(String pName) {
		this.name = pName;
	}
}
